# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Carlo Landmeter <clandmeter@gmail.com>
pkgname=clamsmtp
pkgver=1.10
pkgrel=17
pkgdesc="An SMTP Virus Filter"
url="http://thewalter.net/stef/software/clamsmtp/"
arch="all !s390x"
license="BSD-3-Clause"
install="$pkgname.pre-install $pkgname.pre-upgrade $pkgname.post-upgrade"
subpackages="$pkgname-doc $pkgname-openrc"
source="http://deb.debian.org/debian/pool/main/c/clamsmtp/clamsmtp_$pkgver.orig.tar.gz
	clamsmtpd.confd
	clamsmtpd.initd
	"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	cd "$builddir"
	default_prepare
	update_config_sub
}

check() {
	cd "$builddir"
	make check
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	# set default clam address and user
	sed -e 's|^\#ClamAddress:.*|ClamAddress: /var/run/clamav/clamd.sock|'\
		-e 's|^\#User:.*|User: clamav|' \
		-i doc/clamsmtpd.conf

	install -Dm644 doc/clamsmtpd.conf "$pkgdir"/etc/clamsmtpd.conf
	install -Dm755 "$srcdir"/clamsmtpd.initd "$pkgdir"/etc/init.d/clamsmtpd
	install -Dm644 "$srcdir"/clamsmtpd.confd "$pkgdir"/etc/conf.d/clamsmtpd
	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

sha512sums="f28e2c1d78c965245d8d7a8810fbeb11d41e40383eba2e8fca500f94c2e4b8d9a2c0b9e4e8e967965bf50266968e0b9549fb62369f37724350a20174c89a044b  clamsmtp_1.10.orig.tar.gz
007b948a11ab4c8da737328d2088abd5b66dc7f83bf1b8bcb26a5deb639864e77553b7e7434139ddb8a916fe39beb4aabb35f766ce96274449b414268703a6ee  clamsmtpd.confd
2540bcafa866249cd63cb961c4d589eca900e9d1bedfc06c5ae890118fd9e49f1bd126e6dc23d1d953cc1038b390a2a736b67032e9fb33e70227887a6cbc4a5c  clamsmtpd.initd"
